﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SchoolLibrary.Entity.Person
{
    public class Pupil : Person
    {
        public const string FIND_BY_ID = "SELECT * FROM pupil WHERE id = :id";
        public const string FIND_ALL = "SELECT * FROM pupil";
        public const string SAVE_PUPIL = "INSERT INTO pupil (name, middle_name, surname, class_id) " +
            "VALUES(:name, :middleName, :surname, :classId)";
        public const string UPDATE_PUPIL = "UPDATE pupil SET name = :name, middle_name = :middleName, " +
            "surname = :surname, class_id = :classId where id = :id";
        public const string FIND_BOOK_HOLDERS_BY_CLASS_ID = "select p.* from pupil p inner join registry_journal r  on r.pupil_id = p.id where r.return_date is not null and  class_id = :classId ";

        public const string CLASS_ID_COLUMN_NAME = "class_id";

        private Class pupilClass;

        public Class PupilClass
        {
            get { return pupilClass; }
            set { pupilClass = value; }
        }

        public override string ToString()
        {
            return this.AbbreviatedName;
        }
    }
}
